<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta charset="UTF-8">
		<title>共富网-红包</title>
		<link href="/game/redpack/css/redPacket.css" type="text/css"
		rel="stylesheet" />
		<script type="text/javascript" src="/v3/js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="/game/redpack/js/jquery.hbalerts.js"></script>
	</head>
	<body>
	<div class="wztkjPopUpBox" style="display:none;">
		<div class="wztkjPopUpBoxMain">
			<div class="wztkjPopUpBoxContent1">
				<img src="/game/redpack/images/popUpBoxMark_03_06.png" />
			</div>
			<div class="wztkjPopUpboxBg">
				<div class="wztkjPopUpBoxContent2"></div>
				<div class="wztkjPopUpBoxContent3">
					<p class="wztkjPopUpboxP">取消</p>
					<p class="wztkjPopUpboxP1">确定</p>
					<div style="display:none;"></div>
				</div>
				<div class="wztkjPopUpBoxContent4" style="display:none;">确定</div>
			</div>
		</div>
		</div>
		
		<div class="robAfterMain useRMain">
			<div class="wztSurplusTop">
					<div class="wztSurplusNumber">体验金余额:<span class="useRname">${availableEliteMap.amount }</span>元</div>
             		   <div class="wztSurplus-plin">余额可以发红包分享给好友哦~</div>
				<ul id="box" class="reEselecttit">							
					<li id='box1' class="cls1"> 体验金投资</li>
					<li id='box2' onclick="fhb()">发红包</li>
					<div style="clear:both;"></div>
				</ul>
				
				<div class="liebiaophone" style="display:">
					<div class="rebodyinput1">
						<span class="liebiaophonespan">体验金:</span>
						<input type="type" id="availableElite" value="${availableEliteMap.amount }" disabled="disabled"/>
						<em>元</em>
						<div style="clear:both;"></div>
					</div>
					<div class="rebodyinput1">
						<span class="liebiaophonespan">收益:</span>
						<input type="type" id="exp" value="0" disabled="disabled"/>
						<em>元</em>
						<div style="clear:both;"></div>
					</div>
				
					<div class="wxAlertCMBotton wxAlertCMBottonRest" style="margin-bottom: 100px;">
						<p onclick="cz()"  class="wxAlert">体验金一键投资</p>
					</div>
				</div>
				<p class="useRHint">*最低50元起投，一键将所有体验金换成收益</p>
					
			</div>
			
		<!-- 底部-余额可以分享给好友奥~ -->
		
		<div class="robAfterBintbBottom useRBottom">
		<%-- <a href="/redpackRechargeList.do" class="robAfterMbBintContent">查看我的充值记录</a> --%>	
		</div>	

		<script type="text/javascript">
			function cz(){
				if($('#availableElite').val() < 50){
					jAlert("体验金投资最小金额50元", '提示信息');
					return;
				}
				window.location.href = "/wchatEliteInvest.do";
			}
			
			function fhb(){
				window.location.href = "/redPackInit.do";
			}
			
			function getTotalProfit() {
				var investAmount = Number($('#availableElite').val());
				var annualRate = Number('${lastEliteProduct.annualRate}');
				var deadline = Number('${lastEliteProduct.deadline}');
				var isDayThe = Number('${lastEliteProduct.isDayThe}');
				var profit =  0.00;
				if(isDayThe == 1){
					profit = round(investAmount * annualRate /(12 * 100) * deadline , 2);
				}else if (isDayThe == 2){
					profit = round(investAmount * annualRate /(360 * 100) * deadline , 2);
				}		
				$("#exp").val(round(profit,2));
			}

			// 四舍六入五成双
			function round(num, digit){
			    var ratio = Math.pow(10, digit),
			        _num = num * ratio,
			        mod = _num % 1,
			        integer = Math.floor(_num);
			    if(mod > 0.5){
			        return (integer + 1) / ratio;
			    }else if(mod < 0.5){
			        return integer / ratio;
			    }else{
			        return (integer % 2 === 0 ? integer : integer + 1) / ratio;
			    }
			}
		
			$(function(){
				getTotalProfit();
				$("#box1").click(function(){
					$('.liebiaophone').show();
					$("#box2").removeClass('cls2');
					$("#box1").addClass('cls1');
					$(".liebiaoTrue1").show();
					$(".liebiaoTrue2").hide();
					$('html,body').animate({scrollTop:$('#box1').offset().top}, 800);
					$('.wztSurplusHint').show();
				});
				
			});
		</script>	
</body>
</html>